﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using T4._4.Models;

namespace T4._4.Controllers
{
    public class LoginController : Controller
    {
        public SchoolEntities _context;
        public LoginController()
        {
            _context = new SchoolEntities();
        }
        // GET: Login

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Index(string username, string pwd)
        {
            var user = _context.Users.FirstOrDefault(x => x.Username == username);
            if (user == null)
            {
                ViewBag.Msg = "666";
            }
            else
            {
                if (user.Password == pwd)
                {
                    Session["user"] = user;
                    return RedirectToAction("index", "Default"); ;
                }
                else
                {
                    ViewBag.Msg = "nbhxd";
                }

            }
        }
    }
}